About 967 letters

About 5 minutes

#classmethod

Description: Wraps a method as a class method. See also the staticmethod function.

def classmethod(fn):
    '''
    Wraps a method as a class method

    :param fn: The method to wrap
    :return: The wrapped method
    '''

Example:

class Cat:

    @classmethod
    def speak(cls):
        print('Meow meow meow')

# Call via class
Cat.speak()

# Call via instance
cat = Cat()
cat.speak()

>>> Establishing WebAssembly Runtime.

>>> Standby.

Powered by Shift.

Updated: 6/9/2025

Author: PlanC

Created: 6/9/2025